<?php
session_start();
if (!isset($_SESSION["admin_id"])) {
    header("Location: admin.php");
    exit;
}

require_once "includes/db.php"; // Veritabanı bağlantısı

if ($_SERVER["REQUEST_METHOD"] === "POST") {
    $course_name = $_POST["course_name"];
    $course_description = $_POST["course_description"];

    $stmt = $conn->prepare("INSERT INTO courses (name, description) VALUES (?, ?)");
    $stmt->execute([$course_name, $course_description]);

    header("Location: admin_dashboard.php");
    exit;
}
?>

<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <title>Ders Ekle</title>
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
    <h2>Ders Ekle</h2>
    <form action="add_course.php" method="post">
        <input type="text" name="course_name" placeholder="Ders Adı" required>
        <textarea name="course_description" placeholder="Ders Açıklaması" required></textarea>
        <button type="submit">Ekle</button>
    </form>
    <p><a href="admin_dashboard.php">Geri dön</a></p>
</body>
</html>
